module {
  func.func @sum_to(%n: index) -> i64 {
    %c0 = arith.constant 0 : index
    %c1 = arith.constant 1 : index
    %zero = arith.constant 0 : i64

    %result = scf.for %i = %c0 to %n step %c1 iter_args(%acc = %zero : i64) -> i64 {
      %i_cast = arith.index_cast %i : index to i64
      %next = arith.addi %acc, %i_cast : i64
      scf.yield %next : i64
    }
    return %result : i64
  }
}
